
cc.Class({
    extends: cc.Component,

    properties: {
        infoNode:cc.Node,
        pauseAts:[cc.SpriteFrame],
        geziNode:cc.Node
    },

    onLoad(){
        this.isPause = false;
        //刷新地图
        for(var i = 0;i<this.geziNode.childrenCount;i++){
            var cn = this.geziNode.getChildren()[i];
            if(cn.name !="1" && cn.name !="2" && cn.name !="3" && cn.name !="4" && cn.name !="5" && cn.name !="6" && cn.name !="7" && cn.name !="didu"){
                this.loadres(cn,"close");
            }
        }
    },

    btnsAction(e,f){
        var node = cc.instantiate(cc.globalRes["prefab_createPanel"]);
        node.getComponent("createPanel").setInfo(e.target);
        node.parent = this.node;
    },

    loadres(node,type){
        var path = "gameAts/";
        switch(type){
            case "close":path += "jinzhi";break;
        }
        cc.loader.loadRes(path, cc.SpriteFrame, function (err, spriteFrame) {
		    if (err) {
		        cc.error(err.message || err);
		        return;
		    }
            node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
            node.getComponent(cc.Button).interactable = false;
		});
    },

    //暂停继续
    pauseAction(){
        cc.director.getScheduler().setTimeScale(1);
        this.isPause = !this.isPause;
        if(this.isPause==true){
            this.infoNode.getChildByName("btns").getChildByName("zanting").getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.pauseAts[0];
            this.scheduleOnce(function () {
                cc.game.pause();
              }, 0.1);
        }else{
            cc.game.resume();
            this.infoNode.getChildByName("btns").getChildByName("zanting").getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.pauseAts[1];
        }  
    },


    kuaijin1(){
        // 2倍速
        cc.director.getScheduler().setTimeScale(2);
    },

    kuaijin2(){
        // 3倍速
        cc.director.getScheduler().setTimeScale(3);
    },


});
